package com.hbsoft.util;


import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;


public class ReadConfig
{
	private static ReadConfig rcf;
	private static String databaseType = "1";
	
	private static String ip = "localhost";
	private static String port = "1433";
	private static String databasename = null;
	
	private static String sqlDriver = null;
	private static String sqlUrl = null;
	private static String sqlUsername = null;
	private static String sqlPassword = null;
	
	private static String mySqlDriver = null;
	private static String mySqlUrl = null;
	private static String mySqlUsername = null;
	private static String mySqlPassword = null;

	private static String oracleDriver = null;
	private static String oracleUrl = null;
	private static String oracleUsername = null;
	private static String oraclePassword = null;
	private static String oracleport = "1521";
	
	public static ReadConfig getInstance(){
		if(rcf==null){
			rcf = new ReadConfig();
		}
		return rcf;
	}
	
	public ReadConfig(){
		Properties p = new Properties();
		try {
			p.load(this.getClass().getResourceAsStream("config.properties"));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		databaseType = p.getProperty("databaseType");
		databasename = p.getProperty("databasename");
		
		if("0".equals(databaseType))
		{
			sqlDriver =  p.getProperty("sqlDriver");
			sqlUrl = p.getProperty("sqlUrl");
			sqlUsername = p.getProperty("sqlUsername");
			sqlPassword = p.getProperty("sqlPassword");
		}
		else if("1".equals(databaseType))
		{
			mySqlDriver = p.getProperty("mySqlDriver");
			mySqlUrl = p.getProperty("mySqlUrl");
			mySqlUsername = p.getProperty("mySqlUsername");
			mySqlPassword = p.getProperty("mySqlPassword");
		}
		else if("2".equals(databaseType))
		{
			oracleDriver = p.getProperty("oracleDriver");
			oracleUrl = p.getProperty("oracleUrl");
			oracleUsername = p.getProperty("oracleUsername");
			oraclePassword = p.getProperty("oraclePassword");
		}
	}

	public static String getIp() {
		return ip;
	}

	public static String getMySqlDriver() {
		return mySqlDriver;
	}

	public static String getMySqlPassword() {
		return mySqlPassword;
	}

	public static String getMySqlUrl() {
		return mySqlUrl;
	}

	public static String getMySqlUsername() {
		return mySqlUsername;
	}

	public static String getPort() {
		return port;
	}

	public static String getDatabasename() {
		return databasename;
	}

	public static String getSqlDriver() {
		return sqlDriver;
	}

	public static String getSqlPassword() {
		return sqlPassword;
	}

	public static String getSqlUrl() {
		return sqlUrl;
	}

	public static String getSqlUsername() {
		return sqlUsername;
	}

	public static String getOracleDriver() {
		return oracleDriver;
	}

	public static String getOraclePassword() {
		return oraclePassword;
	}

	public static String getOracleUrl() {
		return oracleUrl;
	}

	public static String getOracleUsername() {
		return oracleUsername;
	}

	public static String getOracleport() {
		return oracleport;
	}

	public static ReadConfig getRcf() {
		return rcf;
	}

	public static String getDatabaseType() {
		return databaseType;
	}
	
	
}
